<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/commons/script.jsp" %>
<script src="${ctx}/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="${ctx}/js/validate.addmethod.js" type="text/javascript"></script>
<script src="${ctx}/js/messages_cn.js" type="text/javascript"></script>
<script src="${ctx}/js/util.js" type="text/javascript"></script>
<title>添加用户</title>
</head>
<body>
  <div class="m_right">
    <div class="m_r_tips">
       <div class="m_r_lefttips">您现在的位置：<a href="${ctx}/admin/home.jsp">首页</a>&gt;系统管理&gt;账号管理&gt;编辑账号</div>
       <jsp:include page="/commons/admin/admin_login_remind.jsp"/>
    </div>

    <s:form id="account_form" method="post" action="editPcAccount" namespace="/admin/account">
    <s:hidden name="acc.aid"/>
    <s:hidden name="acc.type" value="0"/>
    <s:hidden name="acc.createUser.aid"/>
    <s:hidden name="acc.organization.oid"/>
    <div class="m_r_search">
       <div class="m_r_search_con">
         <table width="700" border="0" cellspacing="0" cellpadding="0" align="center"  style="border-collapse: collapse;border-spacing: 0; border:0;margin:0px auto; ">
              <tr>
                <td class="m_r_s_con_td">&nbsp;</td>
                <td class="m_r_s_con_text">&nbsp;</td>
              </tr>
		      <tr>
                <td class="m_r_s_con_td"><span class="required_mark">*</span>所属机构</td>
                <td class="m_r_s_con_text">&nbsp;
                <s:textfield name="acc.organization.name" cssClass="text_input" disabled="true"/>
              </tr>
			<tr>
                <td class="m_r_s_con_td"><span class="required_mark">*</span>用户编号</td>
                <td class="m_r_s_con_text">&nbsp;
                <s:textfield name="acc.numbers" id="numbers" cssClass="text_input" maxlength="50"/>
                </td>
              </tr>  
			<tr>
                <td class="m_r_s_con_td"><span class="required_mark">*</span>登录名</td>
                <td class="m_r_s_con_text">&nbsp;
                <s:textfield name="acc.username" id="username" cssClass="text_input" readonly="true" disabled="true"/>
                </td>
              </tr>  
			<tr>
                <td class="m_r_s_con_td"></td>
                <td class="m_r_s_con_text">&nbsp;
                <span class="required_mark">如果不需要修改密码，请保持密码栏为空。</span>
                </td>
              </tr>  
			<tr>
               <td class="m_r_s_con_td"><span class="required_mark">*</span>新密码</td>
                <td class="m_r_s_con_text">&nbsp;
                 <input type="password" name="acc.password" id="password" class="text_input encode_pw" maxlength="32"/>
                </td>
              </tr> 
              <tr>
                <td class="m_r_s_con_td"><span class="required_mark">*</span>密码确认</td>
                <td class="m_r_s_con_text">&nbsp;
                <input type="password" name="confirm_password" id="confirm_password" class="text_input encode_pw" maxlength="32"/>
                </td>
              </tr>
              <tr>
                <td class="m_r_s_con_td"><span class="required_mark">*</span>姓名</td>
                <td class="m_r_s_con_text">&nbsp;
                <s:textfield name="acc.realname" id="realname" cssClass="text_input" maxlength="20"/>
                </td>
              </tr> 
              <tr>
                <td class="m_r_s_con_td"><span class="required_mark">*</span>邮箱</td>
                <td class="m_r_s_con_text">&nbsp;
                <s:textfield name="acc.email" id="email" cssClass="text_input" readonly="true" disabled="true"/>
                </td>
              </tr> 
              <tr>
                <td class="m_r_s_con_td"><span class="required_mark">*</span>手机</td>
                <td class="m_r_s_con_text">&nbsp;
                <s:textfield name="acc.mobile" id="mobile" cssClass="text_input" disabled="true"/>
                </td>
              </tr>
              <tr>
                   <td class="m_r_s_con_td">职务</td>
                   <td class="m_r_s_con_text">&nbsp;
                        <s:select list="#request.dutyMap" name="acc.dutyCode" cssClass="text_input" listKey="key" listValue="value"  headerKey="" headerValue="无"/>
                   </td>
              </tr> 
              <tr>
                   <td class="m_r_s_con_td"><span class="required_mark">*</span>使用状态</td>
                   <td class="m_r_s_con_text">&nbsp;
                      <s:radio list="#{'false':'正常','true':'禁用'}" name="acc.disabled"/>
                   </td>
              </tr>
              <tr>
                <td width="90" class="m_r_s_con_td">&nbsp;</td>
                <td class="m_r_s_con_text">&nbsp;</td>
              </tr>
         </table>  
       </div>
    </div>
    
    <div class="m_r_search_btn">
      <a href="#" class="m_r_bnt1 pad15"><s:submit value="修改" /></a>
    </div>
    
    <div id="menuContent" class="menuContent" style="display:none; position: absolute;">
        <ul id="orgTree" class="ztree" style="margin-top:0; width:200px;"></ul>
    </div>
    </s:form>
  </div>
</body>
<script type="text/javascript">
   
	$(document).ready(function(){			
			$.validator.setDefaults({
			    submitHandler: function(form) { 
			        var password = $(".encode_pw");
			        $.each(password, function(i,n){
			        	if(n.value != '')
			        		n.value = hex_md5(n.value); 
			        });
			        form.submit(); //不能用$("#id").submit() 会导致死循环
			    }
			});
		  $("#account_form").validate({
		        ignore: "",  // 开启hidden验证， 1.9版本后默认关闭
		        rules: {
		        	"acc.organization.oid":"required",
		            "acc.username": {
		            	required: true,
		            	registerName: true//, //只能是英文开头 包括数字下划线
		            	//remote:"${ctx}/admin/account/isValidName.do"  //传递参数为"acc.username"
		            },
		            "acc.numbers": {
		                required: true,
		                maxlength: 100
		            },
		            "acc.realname": {
		                required: true,
		                maxlength: 100,
		                stringCheck: true
		            },
		            "acc.email": {
		            	required: true,
		            	email:true//,
		            	//remote:"${ctx}/admin/account/isValidEmail.do"  //传递参数为"acc.email"
		            },
		            "acc.password": {
		                required: false,
		                minlength: 6,
		                maxlength: 32
		            },
		            "confirm_password": {
		                required: false,
		                equalTo: "#password"
		            }
		        },
		      messages: {
		            "acc.organization.oid": "请选择机构",
		            "acc.realname": {
		            	required:"请输入姓名",
		            	maxlength:"姓名长度不能超过100"
		            },
		            "acc.username": {
		                required: "请输入合法的用户名",
		                registerName: "只能英文字母开头、可以包括数字和下划线，长度5-16之间",
		                remote:"用户名已经被占用"
		            },
		            "acc.email": {
  	            	   required: "请输入邮箱",
		               email:"请输入正确的邮箱格式",
		               remote:"该邮箱已经被占用"	
		            },
		            "acc.password": {
		                required: "请输入密码",
		                minlength: "密码长度至少为6",
		                maxlength:"密码长度不能超过32"
		            },
		            "confirm_password": {
		                required: "请输入确认密码",
		                equalTo: "确认密码不一致"
		            }
		        }
		    });  
	});
	
</script>
</html>